import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'HomePage.dart';
import 'OrderListPage.dart';
import 'PersonalPage.dart';
import 'SettingsPage.dart'; // 1. 导入 SettingsPage

class NavigationPage extends StatefulWidget {
  @override
  _NavigationPageState createState() => _NavigationPageState();
}

class _NavigationPageState extends State<NavigationPage> {
  int _currentIndex = 0;
  final List<Widget> _children = [
    HomePage(),
    OrderListPage(),
    SettingsPage(),
    PersonalPage(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _children[_currentIndex], // 根据当前的索引来显示对应的页面
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        items: [
          BottomNavigationBarItem(
            backgroundColor: Colors.blueGrey,
            icon: Icon(Icons.home),
            label: '首页',
          ),
          BottomNavigationBarItem(
            backgroundColor: Colors.blueGrey,
            icon: Icon(Icons.list),
            label: '订单',
          ),
          BottomNavigationBarItem(
            backgroundColor: Colors.blueGrey,
            icon: Icon(Icons.settings),
            label: '设置',
          ),
          BottomNavigationBarItem(
            backgroundColor: Colors.blueGrey,
            icon: Icon(Icons.person),
            label: '个人',
          ),
        ],
        onTap: (index) {
          setState(() {
            _currentIndex = index; // 更新当前的索引
          });
        },
      ),
    );
  }
}